package us.wb2b.clearresponse.us.wb2b.clearresponse;
import java.io.IOException;


import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

import us.wb2b.clearresponse.R;
import android.app.Activity;
import android.os.Bundle;
import android.provider.Settings.System;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;


public class main extends Activity {
    /** Called when the activity is first created. */
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        /* Getting unique ID */
        final String android_id = System.getString(this.getContentResolver(), System.ANDROID_ID);
        
        
        
        Button btnFive = (Button) findViewById(R.id.fivemin);
        btnFive.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
            	/* Get the Message to send to the system */
                EditText textMsg = (EditText)findViewById(R.id.entry);
                final String MSG = (String) textMsg.getEditableText().toString();
                /*Toast.makeText(getBaseContext(),MSG,Toast.LENGTH_SHORT).show();    */	
                
            	HttpClient client = new DefaultHttpClient();
            	HttpGet method = new HttpGet("http://192.168.2.100/clearresponse.php?eta=5&cmd=checkin&uid="+android_id+"&msg="+MSG);
            	try {
					client.execute(method);
				} catch (ClientProtocolException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
            	
                Toast.makeText(getBaseContext(), 
                        "You sent a 5 minute ETA", 
                        Toast.LENGTH_SHORT).show();
            }
        });
        
        Button btnTen = (Button) findViewById(R.id.tenmin);
        btnTen.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {

                EditText textMsg = (EditText)findViewById(R.id.entry);
                final String MSG = (String) textMsg.getEditableText().toString();
                /*Toast.makeText(getBaseContext(),MSG,Toast.LENGTH_SHORT).show();*/                
            	HttpClient client = new DefaultHttpClient();
            	HttpGet method = new HttpGet("http://192.168.2.100/clearresponse.php?eta=10&cmd=checkin&uid="+android_id+"&msg="+MSG);
            	try {
            		client.execute(method);
				} catch (ClientProtocolException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				Toast.makeText(getBaseContext(), 
                        "You sent a 10 minute ETA", 
                        Toast.LENGTH_SHORT).show();
            }
        });
        
	};

        
        
        
};
